using GamFi.API.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace GamFi.API.Persistence.Configurations;

public class ChainConfiguration : IEntityTypeConfiguration<Chain>
{
    /// <inheritdoc />
    public void Configure(EntityTypeBuilder<Chain> builder)
    {
        builder.HasKey(x => x.Id);

        builder.Property(p => p.Name);
        
        builder.Property(p => p.ImageId);

        builder.HasMany(x => x.Tokens)
            .WithOne(y => y.Chain)
            .HasForeignKey(t => t.ChainId)
            .OnDelete(DeleteBehavior.Cascade);
    }
}